<?php
namespace app\manager\controller;
use think\Loader;
/**
 * 后台基础控制器
 */
class Base extends \think\Controller
{
	protected $model = '';
	public function _initialize(){
		$this->model = Loader::model($this->request->controller().'s');
		if(method_exists($this, 'init')){
			$this->init();
		}
	}
	/**
	 * 公用数据添加中间方法
	 */
	public function store($data, $jquery, \Closure $callback){
		$method = $jquery['method'];
		$re = $this->model->$method($data);
		$this->hint($re,$jquery);
	}
	/**
	 * 操作提示
	 */
	public function hint($re,$jquery){
	    if($re['code'] == 'failed'){
	    	$this->error($re['msg'],$jquery['error']);
	    }else{
	    	$this->success('操作成功',$jquery['success']);
	    }
	}
	
}

?>